export default {
  data() {
    return {
      // 链接类型
      linkTypeActive: '1',
      // 链接表单
      linkForm: {}
    }
  },
  mounted() {
  },
  methods: {
    // 链接类型切换事件
    doChangeLinkType(type) {
      this.linkTypeActive = type
    },
    // 链接选择事件
    doSetLinkType(linkType, linkRemark, linkParams) {
      this.linkForm.linkParams = ''
      this.linkForm.linkType = linkType
      this.linkForm.linkRemark = linkRemark
      if (linkType === '1101' && linkParams) {
        this.linkForm.linkParams = '?pageId=' + linkParams.pageId
      }
      this.$emit('selectLink', this.linkForm)
    },
    // 分类链接选择事件
    doSetLinkCategory(oneCategoryObj, twoCategoryObj, threeCategoryObj, appType) {
      const linkRemark = threeCategoryObj.categoryName || twoCategoryObj.categoryName || oneCategoryObj.categoryName
      let linkParams
      if (appType * 1 === 13) {
        linkParams = `{"categoryId": "${oneCategoryObj.enterpriseCategoryId}"}`
      } else {
        linkParams = '/pages/shop/main?categoryType=2&categoryId=' + oneCategoryObj.enterpriseCategoryId
        if (twoCategoryObj.categoryName) {
          linkParams += '&secondCategoryId=' + twoCategoryObj.enterpriseCategoryId
        }
        if (threeCategoryObj.categoryName) {
          linkParams += '&thirdCategoryId=' + threeCategoryObj.enterpriseCategoryId
        }
      }
      this.linkForm.linkType = '1004'
      this.linkForm.linkParams = linkParams
      this.linkForm.linkRemark = '分类链接 - ' + linkRemark
      this.$emit('selectLink', this.linkForm)
    },
    // 商品链接选择事件
    doSetLinkGoods(item) {
      this.linkForm.linkType = '2001'
      this.linkForm.linkParams = '?goodsType=30&goodsId=' + item.goodsId
      this.linkForm.linkRemark = '商品详情 - ' + (item.skuFlag * 1 === 1 ? '多规格' : '单规格')
      this.$emit('selectLink', this.linkForm)
    }
  }
}
